%将仿真结果导出到excel表中
% get_new_data();
load Taiwan_one_day.mat
figure
plot_hist(21,26,V);
figure
plot_hist(32,26,V);

figure
plot_hist(43,44,V);
figure
plot_hist(43,46,V);
figure
plot_hist(44,46,V);


function h=plot_hist(node1,node2,V)
    h=histogram2(V(node1,:),V(node2,:));
    xlabel(['节点' num2str(node1)])
    ylabel(['节点' num2str(node2)])
    zlabel('频数')
end

function get_new_data()
    [P,Q,V,theta,nbus,busname,~,nT]=caseTaiwanMatpower('00:01:00','24:00:00');
    %处理计算失败造成的数据缺失
    V = fillmissing(V,'pchip',2);
    Q = fillmissing(Q,'pchip',2);
    P = fillmissing(P,'pchip',2);
    theta = fillmissing(theta,'pchip',2);
    save Taiwan_one_day.mat

    writematrix(V,'台湾量测数据.xlsx','Sheet','电压量测');
    writematrix(theta,'台湾量测数据.xlsx','Sheet','相角量测');
    writematrix(P,'台湾量测数据.xlsx','Sheet','有功注入量测');
    writematrix(Q,'台湾量测数据.xlsx','Sheet','无功注入量测');
end


